package swing;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class JFrameDemo01 extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JPasswordField passwordField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JFrameDemo01 frame = new JFrameDemo01();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	/**
	 * Create the frame.
	 */
	public JFrameDemo01() {
		setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\Administrator\\Desktop\\217647a8bee7c88e9efb4a11cd2b34e6_175.jpg"));
		setVisible(true);
		setLocation(new Point(600, 500));
		setBackground(Color.WHITE);
		setSize(new Dimension(230, 80));
		setTitle("\u7B2C\u4E00\u4E2Aswing\u7A97\u53E3");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel Username = new JLabel("用户名");
		Username.setBounds(63, 47, 54, 15);
		contentPane.add(Username);
		
		textField = new JTextField();
		textField.setBounds(116, 45, 210, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel password = new JLabel("密  码");
		
		password.setBounds(63, 87, 54, 15);
		contentPane.add(password);
		
		passwordField = new JPasswordField();
		passwordField.setBounds(116, 85, 210, 21);
		contentPane.add(passwordField);
		
		JButton btnNewButton = new JButton("重置");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText("");
			passwordField.setText("");
				
			}
		});
		btnNewButton.setBounds(233, 133, 93, 23);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("登录");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if ("zhangsan".equals(textField.getText())&&"123456".equals(new String(passwordField.getPassword()))) {
					JOptionPane.showMessageDialog(null, "登录成功","title", JOptionPane.NO_OPTION);
				} else {
					JOptionPane.showMessageDialog(null, "登录失败","title", JOptionPane.NO_OPTION);	
				}
				
			}
		});
		btnNewButton_1.setBounds(134, 133, 93, 23);
		contentPane.add(btnNewButton_1);
		JFrame f=new JFrame("第一个swing窗体");
		Dimension d=new Dimension();
		d.setSize(230,80);
		Point p=new Point(300, 200);
		
	}
}
